home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / tcoop10a.zip / DOC.ZIP / ITEM.DOC < prev    next >
Text File  |  1991-11-20  |  3KB  |  69 lines

  1. ITEM.DOC        11/10/91        Copyright (c) 1991 by James S. Clark
  2. ==========================================================================
  3. ITEM
  4. Item Class
  5. --------------------------------------------------------------------------
  6. Class Name                      Item
  7. Superclass                      Node
  8. Category                        List
  9. Other classes referenced        <node>
  10. Other catagories referenced     <none>
  11. Used by                         <none>
  12. Inherited by                    <none>
  13.  
  14. Declaration                     List    *list = new List;
  15. Instance Variables
  16.                                 char    *name;
  17. Instance Methods
  18.                                 Item    (char *newname)
  19.                                 ~Item   (void)
  20.                                 static  compare (void *node1, void *node2)
  21.                                 static  find    (void *node1, void *data)
  22.                                 void    print   (void)
  23. --------------------------------------------------------------------------
  24. GENERAL DESCRIPTION
  25.  
  26. The Item Class is derived from the Node Class and can therefore be used
  27. by the List and Tree Classes as well as classes derived from them.  To
  28. the basic Node Class it adds a pointer to the Item name and also special
  29. methods to compare, find, and print the item.
  30.  
  31. The compare and find methods are static so that their addresses may be
  32. passed to a list upon creation.  From that point on the list will call
  33. the compare or find methods as required.
  34.  
  35. --------------------------------------------------------------------------
  36. VARIABLES
  37.  
  38. char    *name;
  39.         Pointer to the item name.
  40.  
  41. --------------------------------------------------------------------------
  42. METHODS
  43.  
  44. Item    (char *newname) { name = strdup(newname); }
  45.                 Creates a new instance of Item and assign newname to
  46.                 the name.
  47.  
  48. ~Item   (void)          { delete name; }
  49.                 Destructor deallocates the name of the Item.
  50.  
  51. static  compare (void *node1, void *node2)
  52.                     { return(strcmp(((Item *) node1)->name,
  53.                                     ((Item *) node2)->name)); }
  54.                 Inline function to perform compare operations between
  55.                 Items in the list.
  56.  
  57. static  find    (void *node1, void *data)
  58.                     { return(strcmp(((Item *) node1)->name,
  59.                                      (char *) data)); }
  60.                 Inline function to perform find operations between
  61.                 an item name and a character array.
  62.  
  63. void    print   (void)  { puts(name); }
  64.                 Prints the name of the Item on the display.
  65.  
  66. --------------------------------------------------------------------------
  67. ITEM.DOC                        Copyright (c) 1991 by James S. Clark
  68. ==========================================================================
  69.